<template>
  <div class="app-container p-rel">
    <div class="container-title">查询</div>
    <el-form :model="queryParams" ref="queryForm" size="small" :inline="true" v-show="showSearch" label-width="85px">
      <el-row :gutter="15">
        <el-col :lg="8" :xl="6">
          <el-form-item label="企业名称" prop="enterpriseName">
            <el-input
              v-model="queryParams.enterpriseName"
              placeholder="请输入企业名称"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
          <el-form-item label="信用代码" prop="creditCode">
            <el-input
              v-model="queryParams.creditCode"
              placeholder="请输入信用代码"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
          <el-form-item label="类型" prop="type">
            <el-select v-model="queryParams.typeIdList" multiple placeholder="请选择类型" clearable style="width: 100%;">
              <el-option
                v-for="dict in dict.type.enterprise_info_type"
                :key="dict.value"
                :label="dict.label"
                :value="dict.value"
              />
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
          <el-form-item label="类别" prop="category">
            <el-select v-model="queryParams.categoryIdList" multiple placeholder="请选择类别" clearable style="width: 100%;">
              <el-option
                v-for="item in categoryList"
                :key="item.id"
                :label="item.categoryName"
                :value="item.id">
              </el-option>
            </el-select>
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
          <el-form-item label="镇/街道" prop="town">
            <el-input
              v-model="queryParams.town"
              placeholder="请输入镇/街道"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
          <el-form-item label="详细地址" prop="addr">
            <el-input
              v-model="queryParams.addr"
              placeholder="请输入详细地址"
              clearable
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
        </el-col>
        <el-col :lg="8" :xl="6">
          <el-button type="primary" icon="" size="" @click="handleQuery">搜索</el-button>
          <el-button icon="" size="" @click="resetQuery">重置</el-button>
        </el-col>
      </el-row>
    </el-form>

    <el-table v-loading="loading" :data="infoList" @selection-change="handleSelectionChange">
      <el-table-column type="index" width="55" align="center" label="序号" />
      <el-table-column label="企业名称" align="center" prop="enterpriseName" />
      <el-table-column label="信用代码" align="center" prop="creditCode" />
      <el-table-column label="类型" align="center" prop="typeListName" width="180px">
        <!--        <template slot-scope="scope">
                  <dict-tag :options="dict.type.enterprise_info_type" :value="scope.row.type"/>
                </template>-->
      </el-table-column>
     <el-table-column label="类别" align="center" prop="categoryListName"/>
      <el-table-column label="镇/街道" align="center" prop="town" />
      <el-table-column label="详细地址" align="center" prop="addr" />
      <el-table-column label="联系电话" align="center" prop="contactNumber" />
      <el-table-column label="监督检查时间" align="center" prop="taskInfoStartTime" width="150px" />
      <el-table-column label="操作" align="center" class-name="small-padding fixed-width" width="150px">
        <template slot-scope="scope">
          <el-button
            size="mini"
            type="text"
            @click="viewLawVideo(scope.row,2)"
          >查看执法过程视频</el-button>
        </template>
      </el-table-column>
    </el-table>

    <pagination
      v-show="total>0"
      :total="total"
      :page.sync="queryParams.pageNum"
      :limit.sync="queryParams.pageSize"
      @pagination="getList"
    />
  </div>
</template>

<script>
  import { auditRecord } from "@/api/zhangping/zpEnterpriseInfo";
  import { categoryList } from "@/api/zhangping/category";
  export default {
    name: "Info",
    dicts: ['enterprise_info_type', 'health_certificate_status', 'business_file_status', 'enterprise_category'],
    data() {
      return {
        // 遮罩层
        loading: true,
        // 选中数组
        ids: [],
        // 非单个禁用
        single: true,
        // 非多个禁用
        multiple: true,
        // 显示搜索条件
        showSearch: true,
        // 总条数
        total: 0,
        // 一企一档表格数据
        infoList: [],
        // 弹出层标题
        title: "",
        // 是否显示弹出层
        open: false,
        // 查询参数
        queryParams: {
          pageNum: 1,
          pageSize: 10,
          enterpriseName: null,
          creditCode: null,
          type: null,
          typeIdList: [],
          categoryIdList: [],
          category: null,
          town: null,
          townCode: null,
          addr: null,
          legalPerson: null,
          contactNumber: null,
          businessLicense: null,
          sanitaryPermit: null,
          sanitaryPermitDate: null,
          healthCertificateStatus: null,
          archivesStatus: null,
          lastUpdateTime: null,
          userId: null,
        },
        // 表单参数
        form: {},
        // 表单校验
        rules: {
        },
        detailForm:{},
        isEdit:false,
        editVisible:false,
        categoryList: [],
      };
    },
    created() {
      this.getList();
      this.getCategoryList()
    },
    methods: {
      /** 查询一企一档列表 */
      getList() {
        this.loading = true;
        auditRecord(this.queryParams).then(response => {
          this.infoList = response.rows
          this.total = response.total;
          this.loading = false;
        });
      },
      // 取消按钮
      cancel() {
        this.open = false;
        this.reset();
      },
      // 表单重置
      reset() {
        this.form = {
          id: null,
          enterpriseName: null,
          creditCode: null,
          type: null,
          category: null,
          town: null,
          townCode: null,
          addr: null,
          legalPerson: null,
          contactNumber: null,
          businessLicense: null,
          sanitaryPermit: null,
          sanitaryPermitDate: null,
          healthCertificateStatus: null,
          archivesStatus: null,
          lastUpdateTime: null,
          userId: null,
          createId: null,
          createBy: null,
          createTime: null,
          updateId: null,
          updateBy: null,
          updateTime: null,
          delFlag: null
        };
        this.resetForm("form");
      },
      /** 搜索按钮操作 */
      handleQuery() {
        this.queryParams.pageNum = 1;
        this.getList();
      },
      /** 重置按钮操作 */
      resetQuery() {
        this.resetForm("queryForm");
        this.handleQuery();
      },
      // 多选框选中数据
      handleSelectionChange(selection) {
        this.ids = selection.map(item => item.id)
        this.single = selection.length!==1
        this.multiple = !selection.length
      },

      /** 查看视频 */
      viewLawVideo(row) {

        alert("查看视频")
      },
      getCategoryList(){
        categoryList().then(response => {
          this.categoryList = response.data;
        });
      }
    }
  };
</script>
